<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.lmpop.trade.ti_teamorder.Ti_teamorderInfo" %>
<%@ page import="com.lmpop.frame.util.PageTools" %>
<%@ page import="com.lmpop.trade.tb_ordergoods.Tb_ordergoodsInfo" %>
<%@ page import="com.lmpop.trade.tb_commpara.Tb_commparaInfo" %>
<%@ page import="com.lmpop.frame.util.Config" %>
<%@ page import="com.lmpop.trade.ti_evaluate.Ti_evaluateInfo" %>
<%@ page import="com.lmpop.trade.ts_categoryattr.Ts_categoryattrInfo" %>
<%@page import="com.lmpop.trade.ts_category.*" %>	
<%!
     public String getPartLength(String key,int num){if(key.equals("")) return "";
		if(key.length()>num) key = key.substring(0,num)+"...";
		return key;
	}
    
	public String getDateStr(String in_date,String type){
		if(in_date.equals("")) return "";
		if(in_date.length()>=10){
			String yeard = in_date.substring(0,4);
			String monthd = in_date.substring(5,7);
			String dayd = in_date.substring(8,10);
			if(type.equals("")){
				in_date = yeard+"-"+monthd+"-"+dayd;
			}else{
				in_date = monthd+"-"+dayd;
			}
		}
		return in_date;
	}

%>



<%
	request.setCharacterEncoding("UTF-8");
	Ti_teamorderInfo ti_orderinfoInfo = new Ti_teamorderInfo();
	Tb_commparaInfo commparaInfo = new Tb_commparaInfo();
	Map params = new Hashtable();
  

  
  String s_order_no="",o_order_state="";
  if(request.getParameter("s_order_no")!=null && !request.getParameter("s_order_no").equals(""))
  {
      s_order_no = request.getParameter("s_order_no"); 
      params.put("order_no",s_order_no);
  }
  if(request.getParameter("o_order_state")!=null && !request.getParameter("o_order_state").equals(""))
  {
      o_order_state = request.getParameter("o_order_state"); 
      params.put("order_state",o_order_state); 
  }
  
	params.put("user_id",_user_id);
 	

 	String iStart = "0";
 	int counter = 0;
	List list = null;
	int limit = 5;
	if(request.getParameter("iStart")!=null) iStart = request.getParameter("iStart");

		counter = ti_orderinfoInfo.getTeamPerCountByObj(params);
		list = ti_orderinfoInfo.getTeamPerListByPage(params,Integer.parseInt(iStart),limit);

	String pageString = new PageTools().getGoogleToolsBar(counter,"index.jsp?o_order_state="+o_order_state+"&s_order_no="+s_order_no+"&menu_id="+menu_id+"&zlpc=lucifer&iStart=",Integer.parseInt(iStart),limit);

	Ts_categoryInfo ts_categoryInfo = new Ts_categoryInfo();
	
	Map catMap  = ts_categoryInfo.getCatClassMap("12");
	String selecttree = ts_categoryInfo.getCategoryTree("000000000000000","12","");

%>

<div class="f-right w750">

<script src="js_order.js"></script>
 <script language="javascript" type="text/javascript" src="/program/plugins/calendar/WdatePicker.js"></script>
 	<script type="text/javascript" src="/js/jquery.js"></script>
	<form action="index.jsp" name="orderForm" method="post">

    <table width="100%" border="0" cellspacing="0" cellpadding="0" >

      <tr>

        <td><table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#eddfea">

            <tr>

              <td width="5%" height="40" align="center"><img src="/program/member/index/images/icon1.gif" ></td>

              <td width="85%"><h3>我的订单</h3></td>

			  <td width="10%"> </td>

            </tr>

          </table>

		     <table width="100%" border="0" cellspacing="0" cellpadding="0" style="border:1px solid #EDDFEA; margin-bottom:10px;">
            <tr>
              <td height="45" align="left">
              	  订单编号:
                  <input type="text" class="input" name ="s_order_no" id= "s_order_no" maxlength="50">	              
			

			  
              	  交易状态:
				  <select id="o_order_state" name="o_order_state">
					  <option value="">请选择</option>
					  <option value="1">未付款</option>
					  <option value="2">交易成功</option>
					  <option value="3">发家发货</option>
					  <option value="4">完成交易</option>
				   </select>                
			 
                  <input type="button" name="Submit" value="搜索" onclick="document.orderForm.submit();"  >
                  </td>
             
            </tr>
          </table>

      <table width="100%" bgcolor="#eddfea"  cellspacing="1" cellpadding="1" border="0" >
			<tr>

				<th width="250" height="32px;">名称</th>

				<th width="50">单价(元)</th>
				 
				<th width="50">总价</th>
				
				<th width="100">下单时间</th>
				
				<th width="70">交易状态</th>
				
				<th width="50">操作</th>
            </tr>
       

		   <%           
		                 String team_path = "/data/teambuy/";
				         String teambuyurl = "";
		                int listsize = 0;
						Hashtable nMap = new Hashtable();
						 List goodslist = new ArrayList();
						if(null != list && list.size() > 0){
						       listsize = list.size();
						for(int i=0;i < list.size();i++){

								nMap = (Hashtable)list.get(i);
								String order_no="",_in_date="",create_date="",price="",total_price="",order_state="",title="",info_id="",y_in_date="",t_in_date="";
								if(nMap.get("order_no")!=null) order_no = nMap.get("order_no").toString();
								
								if(nMap.get("in_date")!=null) _in_date = nMap.get("in_date").toString();
								if(_in_date.length()>19) y_in_date=_in_date.substring(0,19);
								
								if(nMap.get("create_date")!=null) create_date = nMap.get("create_date").toString();
								if(create_date.length()>19) create_date=create_date.substring(0,19);
								
								t_in_date = getDateStr(create_date,"");

								if(nMap.get("price")!=null) price = nMap.get("price").toString();
								if(nMap.get("total_price")!=null){
									 total_price = nMap.get("total_price").toString();
								}
								if(nMap.get("order_state")!=null) order_state = nMap.get("order_state").toString();
								if(nMap.get("info_id")!=null) info_id = nMap.get("info_id").toString();
								if(nMap.get("title")!=null) title = nMap.get("title").toString();
								if (title.length()>100) title=title.substring(0,100);
								teambuyurl = team_path + t_in_date+"/"+info_id+".html";
								
			         %>
		

		    <tr>
				<td height="30" colspan="7" style="background:#EBEBEB;">	   
					订单编号:<%=order_no%>
					&nbsp;
					下单时间: <span style="color:#666666;"><%=y_in_date%></span>
				   
				</td>
			</tr>

			<tr>
				<td width="250" height="60"><a href="<%=teambuyurl%>" target="_blank"><font class="goods_name<%=i%>"><%=title%></font></a></td>  	
				<td width="50"><%=price%></td>
				<td width="50"><%=total_price%></td>
				<td width="100"><%=y_in_date%></td>
				
				<td width="70">
					<%if(order_state.equals("1"))out.println("未付款");%>
					<%if(order_state.equals("2"))out.println("交易成功");%>
					<%if(order_state.equals("3"))out.println("卖家发货");%>
					<%if(order_state.equals("4"))out.println("完成交易");%>
					<a href="teamindex.jsp?order_no=<%=order_no%>&menu_id=<%=menu_id%>" title="查看订单详细"><font color="#BB8600">订单详情</font></a>
				</td>
				<td width="50">
				<%
				  if (order_state.equals("1")){
					
				%>
				<a href="javascript:pay('<%=order_no%>','<%=total_price%>','0','EMS','<%=i%>');" >
				<div style="background:url(/program/member/index/images/orderbg.jpg) repeat-x;width:57px;height:20px;line-height:20px;color:#fff;cursor:pointer;text-align:center;">付款</div>
				</a>	
				<%
				}
				else if (order_state.equals("2")) {
				%>
                  <div style="background:url(/program/member/index/images/orderbg.jpg) repeat-x;width:57px;height:20px;line-height:20px;color:#fff;cursor:pointer;text-align:center;">已付款</div>
				<%
				}
				else if (order_state.equals("3")) {
				%>
                  <div style="background:url(/program/member/index/images/orderbg.jpg) repeat-x;width:57px;height:20px;line-height:20px;color:#fff;cursor:pointer;text-align:center;">卖家发货</div>
				<%
				}
				else if (order_state.equals("4")) {
				%>
                  <div style="background:url(/program/member/index/images/orderbg.jpg) repeat-x;width:57px;height:20px;line-height:20px;color:#fff;cursor:pointer;text-align:center;">完成交易</div>
				<%
				}
				%>
				</td>
            </tr>

			<%
								}
							}
						%>
       </table>

			
         <table width="100%" border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td width="4%" height="35" align="center">
              	<%=pageString%>
              </td>
            </tr>
          </table>


	  <input type="hidden" name="bpm_id" id="bpm_id" value="" />

   </form>
   <form action="/program/jsalipay/index.jsp" name="payment" method="post" >
		<input type="hidden" name="out_trade_no" id="out_trade_no" value=""/>
		<input type="hidden" name="price" id="price" value=""/>
		<input type="hidden" name="subject" id="subject" value=""/>
			<input type="hidden" name="body" id="body" value=""/>
		<input type="hidden" name="logistics_fee" id="logistics_fee" value=""/>
		<input type="hidden" name="logistics_type" id="logistics_type" value=""/>
		<input type="hidden" name="only_kind" value="1"/>
	</form>
  </div>

  <script type="text/javascript">
	function pay(order_no,prices,logistics_fee,logistics_type,i){
		var str = "";
		$(".goods_name"+i).each(function(index){
			str = str + $(this).html()+"|";
		});
		$("#body").val(str);
		$("#out_trade_no").val(order_no);
		$("#price").val(prices);
		alert(prices);
		$("#subject").val(str);
		//$("#logistics_fee").val(logistics_fee);
		//$("#logistics_type").val(logistics_type);
		document.payment.submit();
		
	}
  </script>